package com.glela.controller;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.glela.biz.RedPacketShareHistBiz;
import com.glela.domain.dto.RedpacketRequset;
import com.glela.domain.vo.RedPacketShareHistResponseVo;
import com.glela.domain.vo.RedPacketShareHistVo;
import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.User;
import com.glela.platform.model.response.ResponseBaseModel;
import com.glela.platform.model.response.ResponseResultModel;
import com.glela.platform.service.UserService;
import com.glela.platform.util.ParameterUtils;

@Controller
@RequestMapping(value = "/redPacketShareHist")
public class RedPacketShareHistController {
	private static Logger logger = LoggerFactory.getLogger(RedPacketShareHistController.class);
	
	@Autowired
	private RedPacketShareHistBiz redPacketShareHistBiz;

	@Autowired
	private UserService userService;
	

	
	
	/**
	 * 
	* **********************************************
	* @Title: showRedPacketList 
	* @Description: 显示当前用户的红包分享列表
	* @param @param request
	* @param @return 
	* @return ResponseEntity<?>
	* @throws	
	* @author wy
	* @date 2018年3月23日 
	* **********************************************
	 */
	@SuppressWarnings("rawtypes")
	@ResponseBody
	@RequestMapping(value = "/showRedPacketShareLists", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> showRedPacketShareListsAA(@RequestBody  RedpacketRequset request) {
			try {
			if (ParameterUtils.validParams(request.getUserId())) {
				return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20102), HttpStatus.OK);
			}
			User user = this.userService.getUserById(request.getUserId());
			if (null == user) {
				return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20113), HttpStatus.OK);
			}
			RedPacketShareHistResponseVo result = redPacketShareHistBiz.showRedPacketShareLists(request.getUserId(),request.getStartIndex(),request.getPageSize());
			return new ResponseEntity<>(new ResponseResultModel<>(result), HttpStatus.OK);
		} catch (Exception e) {
			logger.error("获取用户分享红包列表异常", e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}
}
